package queue;

import java.util.LinkedList;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

public class QueueDemo {
    public static void main(String[] args) {
        Queue queue = new LinkedList<String>();
        queue.add("1");
        queue.add("2");
        queue.add("3");
        System.out.println(queue);
        System.out.println(queue.peek());

        BlockingQueue<String> blockingQueue = new ArrayBlockingQueue<>(1);
        blockingQueue.add("a");
        //队列满了再次add会抛异常,offer会返回false
//        blockingQueue.add("b");
        blockingQueue.offer("c");
        System.out.println(blockingQueue);
    }
}
